import { AppCode } from '@/services/config.js'
import axios from 'axios'
let channelListUrl = 'http://ali-news.showapi.com/channelList';
let newsListUrl = 'http://ali-news.showapi.com/newsList';

export async function getChannels() {
  let result = await axios.get(channelListUrl, {
    headers: {
      Authorization: `APPCODE ${AppCode}`,
    }
  })
  return result.data.showapi_res_body.channelList;
}

export async function getNews(channelId, limit = 5, page = 1) {
  let result = await axios.get(newsListUrl, {
      headers: {
        Authorization: `APPCODE ${AppCode}`,
      },
      params: {
        channelId,
        maxResult: limit,
        page,
        needContent: 1
      }
    })
    // return result.data.showapi_res_body.pagebean.contentlist;
  return result.data.showapi_res_body.pagebean;
}